/**
 * 
 */
package vista.informes;

import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import bbdd.informes.Informes;

/**
 * @author teledhil
 * 
 */
public class VentanaParadas extends JFrame implements Runnable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3748461356566864250L;
	private TartaParadas tarta;
	private static String nombreVentana="Tarta Arranques/Paradas";
	private static String tituloTarta="Informe Arranques/Paradas";

	private boolean seguirActualizandose = true;

	@Override
	public void run() {
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		while (seguirActualizandose) {
			tarta = new TartaParadas(tituloTarta, Informes
					.getHashMap());
			this.add(tarta);
			this.pack();
			this.setVisible(true);

			//System.out.println("Me refresco!");
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}


		//System.out.println("No me refresco!");
		this.dispose();
	}

	public VentanaParadas() {

		super(nombreVentana);

		tarta = new TartaParadas(tituloTarta, Informes.getHashMap());
		this.add(tarta);
		this.pack();
		this.setVisible(true);
		this.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(WindowEvent winEvt) {
				// Perhaps ask user if they want to save any unsaved files
				// first.
				seguirActualizandose = false;
			}
		});

		Thread thread = new Thread(this);
		thread.start();

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		@SuppressWarnings("unused")
		Informes informes = new Informes();
		Informes.setSesion_correctos(1);
		Informes.setSesion_incorrectos(2);
		Informes.setTotal_arranques(3);
		Informes.setTotal_correctos(4);
		Informes.setTotal_incorrectos(5);
		Informes.setTotal_paradas_emergencia(6);
		Informes.setTotal_paradas_normales(7);

		@SuppressWarnings("unused")
		VentanaParadas ventanaParadas = new VentanaParadas();

		Informes.setSesion_correctos(1);
		Informes.setSesion_incorrectos(1);
		Informes.setTotal_arranques(1);
		Informes.setTotal_correctos(1);
		Informes.setTotal_incorrectos(1);
		Informes.setTotal_paradas_emergencia(1);
		Informes.setTotal_paradas_normales(1);
	}

}
